# -*- coding:utf-8 -*-

import os
from IConfigParser import IConfigParser

config = IConfigParser()


def read_config(sec, key=""):
    if "" != key:
        return config.get(sec, key)
    _items = config.items(sec)
    # _key_value = {str(it[0]): it[1] for it in _items}
    _key_value = {}
    for it in _items:
        _key_value[str(it[0])] = it[1]
    return _key_value


if 0 == len(config.sections()):
    path = os.path.dirname(os.path.dirname(__file__))
    with open("%s/config.ini" % path, "r") as fp:
        config.readfp(fp)
